import 'package:json_annotation/json_annotation.dart';
import '../../common/utils/url_utils.dart';

part 'action_record.g.dart';

/// 行动记录模型
@JsonSerializable()
class ActionRecord {
  /// 创建时间
  @JsonKey(name: 'createTime')
  final String? createTime;

  /// 更新时间
  @JsonKey(name: 'updateTime')
  final String? updateTime;

  /// 参数
  @JsonKey(name: 'params')
  final Map<String, dynamic>? params;

  /// ID
  @JsonKey(name: 'id')
  final int? id;

  /// 行动名称
  @JsonKey(name: 'actionName')
  final String? actionName;

  /// 行动图片
  @JsonKey(name: 'actionImage')
  final String? actionImage;

  /// 行动文件
  @JsonKey(name: 'actionFile')
  final String? actionFile;

  /// 行动阅读时间
  @JsonKey(name: 'actionReadTime')
  final String? actionReadTime;

  /// 描述
  @JsonKey(name: 'description')
  final String? description;

  /// 备注
  @JsonKey(name: 'remarks')
  final String? remarks;

  /// 设备序列号
  @JsonKey(name: 'deviceSn')
  final String? deviceSn;

  /// 用户ID
  @JsonKey(name: 'userId')
  final int? userId;

  ActionRecord({
    this.createTime,
    this.updateTime,
    this.params,
    this.id,
    this.actionName,
    this.actionImage,
    this.actionFile,
    this.actionReadTime,
    this.description,
    this.remarks,
    this.deviceSn,
    this.userId,
  });

  /// 从JSON创建实例
  factory ActionRecord.fromJson(Map<String, dynamic> json) => _$ActionRecordFromJson(json);

  /// 转换为JSON
  Map<String, dynamic> toJson() => _$ActionRecordToJson(this);

  /// 获取完整的图片URL
  String get fullImageUrl {
    return UrlUtils.toFullImageUrl(actionImage);
  }

  /// 获取完整的文件URL
  String get fullFileUrl {
    return UrlUtils.toFullFileUrl(actionFile);
  }
}
